home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
print
/
gs261ini.zip
/
BDFTOPS.PS
< prev
next >
Wrap
Text File
|
1993-05-27
|
24KB
|
749 lines
% Copyright (C) 1990, 1991, 1993 Aladdin Enterprises. All rights reserved.
%
% This file is part of Ghostscript.
%
% Ghostscript is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
% to anyone for the consequences of using it or for whether it serves any
% particular purpose or works at all, unless he says so in writing. Refer
% to the Ghostscript General Public License for full details.
%
% Everyone is granted permission to copy, modify and redistribute
% Ghostscript, but only under the conditions described in the Ghostscript
% General Public License. A copy of this license is supposed to have been
% given to you along with Ghostscript so you can know your rights and
% responsibilities. It should be in a file named COPYING. Among other
% things, the copyright notice and this notice must be preserved on all
% copies.
% bdftops.ps
% Convert a BDF file (possibly with (an) associated AFM file(s))
% to a Ghostscript font.
% Ghostscript fonts are in the same format as Adobe Type 1 fonts,
% except that they do not use eexec encryption.
% See gs_fonts.ps for more information.
/envBDF 120 dict def
envBDF begin
% "Import" the image-to-path package.
% This also brings in the Type 1 opcodes (type1ops.ps).
(impath.ps) run
% "Import" the font-writing package.
(wrfont.ps) run
/encrypt_CharStrings true def
% Invert the StandardEncoding vector.
256 dict dup begin
0 1 255 { dup StandardEncoding exch get exch def } for
end /decoding exch def
% Define the properties copied to FontInfo.
mark
(COPYRIGHT) /Notice
(FAMILY_NAME) /FamilyName
(FULL_NAME) /FullName
(WEIGHT_NAME) /Weight
.dicttomark /properties exch def
% Define the character sequences used to fill in some undefined entries
% in the standard encoding.
mark
(AE) [/A /E]
(OE) [/O /E]
(acute) [/quoteright]
(ae) [/a /e]
(bullet) [/asterisk]
(cedilla) [/comma]
(circumflex) [/asciicircum]
(dieresis) [/quotedbl]
(dotlessi) [/i]
(ellipsis) [/period /period /period]
(emdash) [/hyphen /hyphen /hyphen]
(endash) [/hyphen /hyphen]
(exclamdown) [/exclam]
(fi) [/f /i]
(fl) [/f /l]
(florin) [/f]
(fraction) [/slash]
(germandbls) [/s /s]
(grave) [/quoteleft]
(guillemotleft) [/less /less]
(guillemotright) [/greater /greater]
(guilsinglleft) [/less]
(guilsinglright) [/greater]
(hungarumlaut) [/quotedbl]
(oe) [/o /e]
(periodcentered) [/asterisk]
(questiondown) [/question]
(quotedblbase) [/comma /comma]
(quotedblleft) [/quotedbl]
(quotedblright) [/quotedbl]
(quotesinglbase) [/comma]
(quotesingle) [/quoteright]
(tilde) [/asciitilde]
.dicttomark /composites exch def
% Note the characters that must be defined as subroutines.
96 dict begin
0 composites
{ exch pop
{ dup currentdict exch known
{ pop }
{ 1 index def 1 add }
ifelse
}
forall
}
forall pop
currentdict
end /subrchars exch def
% Define the overstruck characters that can be synthesized with seac.
mark
[ /Aacute /Acircumflex /Adieresis /Agrave /Aring /Atilde
/Ccedilla
/Eacute /Ecircumflex /Edieresis /Egrave
/Iacute /Icircumflex /Idieresis /Igrave
/Lslash
/Ntilde
/Oacute /Ocircumflex /Odieresis /Ograve /Otilde
/Scaron
/Uacute /Ucircumflex /Udieresis /Ugrave
/Yacute /Ydieresis
/Zcaron
/aacute /acircumflex /adieresis /agrave /aring /atilde
/ccedilla
/eacute /ecircumflex /edieresis /egrave
/iacute /icircumflex /idieresis /igrave
/lslash
/ntilde
/oacute /ocircumflex /odieresis /ograve /otilde
/scaron
/uacute /ucircumflex /udieresis /ugrave
/yacute /ydieresis
/zcaron
]
{ dup dup length string cvs
[ exch dup 0 1 getinterval
exch dup length 1 sub 1 exch getinterval
]
} forall
/cent [/c /slash]
/daggerdbl [/bar /equal]
/divide [/colon /hyphen]
/sterling [/L /hyphen]
/yen [/Y /equal]
.dicttomark /accentedchars exch def
% ------ BDF file parsing utilities ------ %
% Define a buffer for reading the BDF file.
/buffer 400 string def
% Read a line from the BDF file into the buffer.
% Define /keyword as the first word on the line.
% Define /args as the remainder of the line.
% If the keyword is equal to commentword, skip the line.
% (If commentword is equal to a space, never skip.)
/nextline
{ bdfile buffer readline not
{ (Premature EOF\n) print stop } if
( ) search
{ /keyword exch def pop }
{ /keyword exch def () }
ifelse
/args exch def
keyword commentword eq { nextline } if
} bind def
% Get a word argument from args. We do *not* copy the string.
/warg % warg -> string
{ args ( ) search
{ exch pop exch }
{ () }
ifelse /args exch def
} bind def
% Get an integer argument from args.
/iarg % iarg -> int
{ warg cvi
} bind def
% Get a numeric argument from args.
/narg % narg -> int|real
{ warg cvr
dup dup cvi eq { cvi } if
} bind def
% Convert the remainder of args into a string.
/remarg % remarg -> string
{ args copystring
} bind def
% Get a string argument that occupies the remainder of args.
/sarg % sarg -> string
{ args (") anchorsearch
{ pop /args exch def } { pop } ifelse
args args length 1 sub get (") 0 get eq
{ args 0 args length 1 sub getinterval /args exch def } if
args copystring
} bind def
% Check that the keyword is the expected one.
/checkline % (EXPECTED-KEYWORD) checkline ->
{ dup keyword ne
{ (Expected ) print =
(Line=) print keyword print ( ) print args print (\n) print stop
} if
pop
} bind def
% Read a line and check its keyword.
/getline % (EXPECTED-KEYWORD) getline ->
{ nextline checkline
} bind def
% Find the first/last non-zero bit of a non-zero byte.
/fnzb
{ 0 { exch dup 128 ge { pop exit } { dup add exch 1 add } ifelse }
loop
} bind def
/lnzb
{ 7 { exch dup 1 and 0 ne { pop exit } { -1 bitshift exch 1 sub } ifelse }
loop
} bind def
% ------ Type 1 encoding utilities ------ %
% Parse the side bearing and width information that begins a CharString.
% Arguments: charstring. Result: mark sbx wx substring *or*
% mark sbx sby wx wy substring.
/parsesbw
{ mark exch lenIV
{ % stack: mark ... string dropcount
dup 2 index length exch sub getinterval
dup 0 get dup 32 lt { pop exit } if
dup 246 le
{ 139 sub exch 1 }
{ dup 250 le
{ 247 sub 8 bitshift 108 add 1 index 1 get add exch 2 }
{ dup 254 le
{ 251 sub 8 bitshift 108 add 1 index 1 get add neg exch 2 }
{ pop dup 1 get 128 xor 128 sub
8 bitshift 1 index 2 get add
8 bitshift 1 index 3 get add
8 bitshift 1 index 4 get add exch 5
} ifelse
} ifelse
} ifelse
} loop
} bind def
% Find the side bearing and width information that begins a CharString.
% Arguments: charstring. Result: charstring sizethroughsbw.
/findsbw
{ dup parsesbw counttomark 1 add 1 roll cleartomark skipsbw
} bind def
/skipsbw % charstring sbwprefix -> sizethroughsbw
{ length 1 index length exch sub
2 copy get 12 eq { 2 } { 1 } ifelse add
} bind def
% Encode a number, and append it to a string.
% Arguments: str num. Result: newstr.
/concatnum
{ dup dup -107 ge exch 107 le and
{ 139 add 1 string dup 0 3 index put }
{ dup dup -1131 ge exch 1131 le and
{ dup 0 ge { 16#f694 } { neg 16#fa94 } ifelse add
2 string dup 0 3 index -8 bitshift put
dup 1 3 index 255 and put
}
{ 5 string dup 0 255 put exch
2 copy 1 exch -2